<script>
$(document).ready(function(){
	$('#view_date').datepicker({ dateFormat: 'yy-mm-dd' });
	$('#expected_date').datepicker({ dateFormat: 'yy-mm-dd' });
	
})
$(function() {
	     var scntDiv = $('#p_scents');
        var i = $('#p_scents tr').size() + 1;
        
        $('.addScnt').live('click', function() {
                $('<tr id="dd'+ i +'"> <td><input type="text"   name="code[]"id="code'+i+'" onchange="get_product1(this.value,product_name'+i+');"/></td> <td><input type="text"   name="product_name[]"   id="product_name'+i+'" readonly /></td> <td><input type="text" class="span2" name="quantity[]" id="quantity'+ i +'"  /></td> <td><a href="#" class="addScnt">ADD</a>&nbsp;&nbsp;&nbsp;<a href="#"  id="'+i+'" class="remScnt">Remove</a></td></tr>').appendTo(scntDiv);
                i++;
                return false;
        });
		 $('.remScnt').live('click', function() { 
		//alert(i)
		    if( i > 2 ) {
                        
						$(this).parents('tr').remove();
                        i--;
                }
                return false;
        });
        
        
});
 
function get_product(code){
	$.post("<?= site_url('enquiry/enquiry/get_productName')?>",{ code:code }, function(msg){
		if(msg){
			$('#product_name').val(msg)
			}else{
				$('#product_name').val(""),
				alert('No Product Is Available!!')
				}
		
		})
	
	}
	
function get_product1(code,rate){
		var id="#"+$(rate).attr('id')
		$.post("<?= site_url('enquiry/enquiry/get_productName')?>",{ code:code }, function(msg){
		if(msg){
				$(id).val(msg);	

			}else{
				$(id).val(""),
				alert('No Product Is Available!!')
				}
		
		})
	
}	
 
</script>
<h2 style="background-color:#368EE0; color:white; font-size:20px; padding:5px;">Edit Order </h2>
<?php echo form_open(current_url());?>

<!--<div id="infoMessage"><?php echo $message;?></div>-->
<table align="center">
<tr><td><b>SUPPLIER</b></td><td>
            <?php 
	 	$bl[0] = "--Select Supplier--";
	   		foreach($suppliers as $supplier){
				$bl[$supplier->id] = $supplier->name;
			}
			echo form_dropdown('id_supplier', $bl,$user->id_supplier, 'class="chzn-select span12" data-placeholder="Choose a Customer" name="id_customer" id="id_customer" required style="width:220px;"');  ?>
	
<a href="<?=site_url('people/supplier/create_supplier/st')?>" ><i class="icon-edit"></i></a> 
</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr>
<td><b>ENQUIRY NO</b></td> <td><?php echo form_input($order_no);?></td>
</tr>  
<tr>      
<td><b>DATE</b></td><td><?php echo form_input($order_date);?></td>
</tr>
<tr>      
<td><b>EXPECTED DATE</b></td><td><?php echo form_input($expected_date);?>  </td>
</tr>
</table>
<hr>

<table width="100%" class="table table-bordered" >

  <tr style="background-color:#F6F6F6;">
              <td><b>Product Name</b></td>
			  <td><b>Category</b></td>
			  <td><b>Company</b></td>
			  <td><b>Quantity</b></td>
             </tr>
<tbody id="p_scents">           

<?php foreach($products as $pro){?>
  <tr style="background-color:#D1E4FC; border:none;"><label for="p_scnts">
    <td style="border:none;"><input type="text"  name='name[]' id="name"   value="<?= $pro->name?>"/></td>
    <td style="border:none;"><input type="text"   id="category"   name='category[]'  value="<?= $pro->category ?>" /></td>
	<td style="border:none;"><input type="text"  id="company"   name='company[]'  value="<?= $pro->company ?>" /></td>
   <td style="border:none;"><input type="text" class="span2" id="quantity" name='quantity[]' value="<?= $pro->quantity ?>"/></td>
	</label> </tr>
 <?php }?>
  </tbody>
</table>  
<p align="right"><?php echo form_submit('submit', 'Update', 'class="btn btn-success"');?></p>
</form>
<!--<?php echo form_close();?>-->
